﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using RemoteBank.DAL;

namespace RemoteBank.BLL
{
    class RemoteBankBLL
    {
        public bool Login(String UserName, String Password)
        {
            RemoteBankDAL dal = new RemoteBankDAL();
            SqlDataReader reader;
            SqlParameter para;
            List<SqlParameter> ListPara = new List<SqlParameter>();
            para = new SqlParameter("@UserName",SqlDbType.VarChar);
            para.Value = UserName;
            ListPara.Add(para);

            para = new SqlParameter("@Password", SqlDbType.VarChar);
            para.Value = Password;
            ListPara.Add(para);
            reader = dal.ExecuteQuerry_GetDataReader("Login",ListPara);

            if (reader.HasRows)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public SqlDataReader getUserByUserName(string username)
        {
            RemoteBankDAL dal = new RemoteBankDAL();
            SqlParameter para;
            List<SqlParameter> ListPara = new List<SqlParameter>();
            para = new SqlParameter("@UserName", SqlDbType.VarChar);
            para.Value = username;
            ListPara.Add(para);
            return dal.ExecuteQuerry_GetDataReader("getUserByUserName", ListPara);
        }
        //lay ra tat ca Account cua User
        public SqlDataReader getAccountByUserID(int userID)
        {
            RemoteBankDAL dal = new RemoteBankDAL();
            SqlParameter para;
            List<SqlParameter> ListPara = new List<SqlParameter>();
            para = new SqlParameter("@UserID", SqlDbType.VarChar);
            para.Value = userID;
            ListPara.Add(para);
            return dal.ExecuteQuerry_GetDataReader("selectAccountUsersByUserID",ListPara);
        }
    }
}
